import request from '@/utils/request'
import { renderUrl } from '../../utils'

const headers = {
  'Content-Type': 'application/json'
}

export function add(data) {
  return request({
    url: '/admin/role/add',
    method: 'post',
    data: JSON.stringify(data),
    headers
  })
}

export function del(data) {
  return request({
    url: '/admin/role/updRoleStatus',
    method: 'post',
    data: JSON.stringify({
      id: data.id,
      status: -1
    }),
    headers
  })
}

export function edit(data) {
  return request({
    url: '/admin/role/editRole',
    method: 'post',
    data: JSON.stringify(data),
    headers
  })
}

export function getPermissionByRole(data) {
  return request({
    url: `/admin/role/getPrivilegeByRoleAndParent?id=${data.id}`,
    method: 'post',
    headers
  })
}

export function rolePermissionUpdate(data) {
  return request({
    url: '/admin/role/editRolePrivilege',
    method: 'post',
    data: JSON.stringify(data),
    headers
  })
}

export default { add, edit, del }

